import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static Scanner cin = new Scanner(new BufferedInputStream(System.in));//大量输入优化版本
    static PrintWriter cout = new PrintWriter(new BufferedOutputStream(System.out));//大量输出优化版本
    static PrintWriter cerr = new PrintWriter(System.err, true);//开启调试模式,一般输出量不大，不需要buffered

    public static void main(String[] args) {
        //TODO AOJ开启你的ACM传奇人生
        cerr.println("----Start your ACM legendary life with AOJ(www.webturing.com)----");
        int cnt = find("(())()()", "()()()()");
        cout.println(cnt);


        cin.close();//关闭输入流
        cout.close();//关闭输出流，这是必须的，否则一般不会自动刷新缓冲区


    }

    private static int find(String a, String b) {
        cerr.println("a=" + a + ",b=" + b);
        if (a.equals(b)) return 0;
        if (a.length() < b.length()) return -9999;
        int y = b.indexOf(')');
        int x = a.indexOf(')');
        if (x == y) {
            a = a.substring(0, x - 1) + a.substring(x + 1);
            b = b.substring(0, x - 1) + b.substring(y + 1);
            return find(a, b);
        } else {
            a = a.substring(0, x - 1) + a.substring(x + 1);
            return find(a, b) + 1;
        }


    }
}
